/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ages.test.swat

import com.ages.entity.Actor
import com.ages.graphics.GLDraw
import com.ages.graphics.Sprite
import com.ages.graphics.ViewportSwitcher
import com.ages.math.Vector
import com.ages.math.Vector3D
import javax.media.opengl.GL

object SmackFX{
  val spr1 = new Sprite("/com/ages/test/res/smack_small.png",1,1,1)
  val spr2 = new Sprite("/com/ages/test/res/smack_small.png",1,1,1)
  val spr3 = new Sprite("/com/ages/test/res/smack_small.png",1,1,1)
}

class SmackFX(v:Vector) extends Actor {
  val smackType = (Math.random*3).toInt
 depth = DepthPlaces.ABOVE_SWATTER

  pos = Vector3D(v.X,v.Y,1)
  var time = 0
//  val sprite = new Sprite("/com/ages/test/res/smack_small.png",1,1,1)
//  printf("smack confirms being added!...%s, at %s\n",this,pos)
  def think(){
    time += 1
    if(time>10)
      markForDeletion = true
  }

  def draw(gl:GL)
  {
    val spot = Vector3D(pos.X,pos.Y,1)
    val box = () =>{
      gl.glEnable(GL.GL_BLEND);
//     Select blending function
//      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
      gl.glColor4d(1,1,1,1/time)
      gl.glTranslated(-100,-100,0)
      smackType match{
        case 0 => SmackFX.spr1.drawWithoutDisplaylist(gl, 0 , 0)
        case 1 => SmackFX.spr2.drawWithoutDisplaylist(gl, 0 , 0)
        case 2 => SmackFX.spr3.drawWithoutDisplaylist(gl, 0 , 0)
      }
      
    }
//    gl.glDisable(GL.GL_LIGHTING)
    ViewportSwitcher.setup2DView(gl)

    GLDraw draw box at spot on gl

//    println("smackfx being drawn...")

  }
}
